// Copyright 2019 The rhyme_lph Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// P [author] rhyme_lph
// Z [email]  rhymelph@gmail.com
// A [github] https://github.com/rhymelph

import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/generated/l10n.dart';
import 'package:finance_app/src/common/app_spaces.dart';
import 'package:finance_app/src/page/all_reports/views/hightlight_view.dart';
import 'package:finance_app/src/page/all_reports/views/reports_view.dart';
import 'package:finance_app/src/widgets/button/assistant_button.dart';
import 'package:finance_app/src/widgets/common_app_bar.dart';
import 'package:finance_app/src/widgets/common_tab_bar.dart';
import 'package:flutter/material.dart';
import 'package:finance_app/src/provider/all_reports/all_reports_provider.dart';
import 'package:finance_app/src/router_gen/router_meta.dart';

@RouterMeta(paramName: "allReportsPage")
class AllReportsPage extends StatefulWidget {
  @override
  _AllReportsPageState createState() => _AllReportsPageState();
}

class _AllReportsPageState extends State<AllReportsPage>
    with PagePresenter<AllReportsPage, AllReportsProvider> {
  @override
  PreferredSizeWidget get appBar => getDefaultAppBar(
        title: S.current.all_reports,
        actions: [
          AssistantButton(
            entryPoint: "All Reports",
          ),
        ],
      );

  @override
  Widget get buildWidget => ColoredBox(
        color: Colors.white,
        child: DefaultTabController(
          length: provider.tabs.length,
          initialIndex: 1,
          child: Column(
            children: [
              Visibility(
                  visible: false,
                  child: CommonTabBar(
                    tabs: provider.tabs
                        .map((e) => MyTab(
                              text: e,
                            ))
                        .toList(),
                  )),
              Expanded(child: _buildTabBarView()),
            ],
          ),
        ),
      );

  Widget _buildTabBarView() {
    return TabBarView(
      physics: NeverScrollableScrollPhysics(),
      children: [
        HightlightView(),
        ReportsView(),
      ],
    );
  }
}
